This invention relates generally to transaction processing, and more particularly to distributed transaction processing in a network with asynchronous communications in the form of messages.
In distributed databases, a transaction may involve operations to be performed at different sites. The operations in a transaction must be performed atomically (i.e., either all of them are performed or none of them is performed.) Atomic transaction implementation is typically based on a commit protocol, such as the widely used two-phase commit protocol. In a xe2x80x9cpreparexe2x80x9d phase of the two-phase commit protocol, a transaction coordinator asks all resource managers involved in the transaction to vote whether each of them can guarantee the execution of its part of the transaction. If all votes are positive, the transaction coordinator in a xe2x80x9ccommitxe2x80x9d phase asks each resource manager to actually carry out its respective operation.
The implementation of the conventional two-phase commit for distributed transaction processing in a network with asynchronous communications poses significant problems. With asynchronous communications, one application sends a request to a receiving application regardless of whether the receiving application is operating. The request is passed through the network which includes nodes that can come on or off at random intervals. There is no guarantee when the request will reach the receiving application and when the requesting application will receive a response from the receiving application. In the conventional commit process, after sending a positive vote in the prepare phase, a resource manager may have to lock up its resource so that it will be able to fulfill its promise of performing the requested operation when it receives a commit instruction from the transaction coordinator. When applied to distributed databases, the two-phase commit protocol locks up the data in a database involved in the transaction so that no changes requested by other clients can be made. Due to the unpredictable delivery time of asynchronous communications, the database may be locked up for an unacceptably long time and become useless.
In accordance with the present invention, there is provided a method and system for processing distributed transactions that integrates the execution of operations of a transaction on separate computers with the exactly-once in-order message delivery of a message queuing system to allow the transaction operations to be performed atomically and asynchronously. In a distributed transaction, a first application on a first computer requests a local resource manager to perform a first operation and uses a message queue (MQ) server to send a request message to a second application on a remote computer for the performance of a second operation. The local resource manager and the MQ server of the first computer are coordinated to perform the first operation and send the request message in a local committed transaction. The message is delivered exactly once and in sequence to a target message queue for the second application on the remote computer. The second application uses the MQ server of the remote computer to read the message and uses a second resource manager to perform the requested second operation in a second local committed transaction. As part of the second local committed transaction, the MQ server of the remote computer sends an acknowledgment which is delivered by the message queuing system to the MQ server of the first computer.
In accordance with another aspect of the invention, a connector computer is used to bridge two different message queuing systems to allow the processing of a distributed transaction which involves computers in the two message queuing systems. The connector computer is connected to both message queuing systems and has a connector application. When an application in the first message queuing system initiates a transaction and sends a request message to an application on a second computer in the second message queuing system, the message is routed to a message queue of the connector computer. The connector application translates the message into the format of the second message queuing system and forwards the translated message to the second computer.
The advantages of the invention will become apparent with reference to the following detailed description when taken in conjunction with the drawings in which: